package com.pyk.controller;


import com.pyk.entity.Courses;
import com.pyk.entity.Result;
import com.pyk.service.CoursesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/course")
@Slf4j

public class CoursesController {
    @Autowired
    private CoursesService coursesService;

    @GetMapping("/{name}")
    public Result select(@PathVariable String name){
        log.info("根据{}查询课程",name);
        List<Courses> courseslist=coursesService.List(name);
        return Result.success(courseslist);
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id){
        log.info("根据id删除部门：{}",id);
        coursesService.delete(id);
        return Result.success();
    }
    @PostMapping
    public Result add(@RequestBody Courses courses){
        log.info("新增课程：{}",courses);
        coursesService.add(courses);
        return Result.success();
    }

}
